/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrgs.jsopa;

class ProcessList {

    private ProcessDescriptor first = null;
    private ProcessDescriptor last = null;

    public ProcessDescriptor getFront() {
        return first;
    }

    public ProcessDescriptor getBack() {
        return last;
    }

    public ProcessDescriptor popFront() {
        ProcessDescriptor n;
        if (first != null) {
            n = first;
            first = first.getNext();
            if (last == n) {
                last = null;
            }
            n.setNext(null);
            return n;
        }
        return null;
    }

    public void pushBack(ProcessDescriptor n) {
        n.setNext(null);
        if (last != null) {
            last.setNext(n);
        } else {
            first = n;
        }
        last = n;
    }
}
